package com.probox.common.entity.config.platform;

import com.google.code.kaptcha.text.impl.DefaultTextCreator;

import java.util.Random;

/**
 * 验证码文本生成器
 *
 * @author usoft
 */
public class KaptchaTextCreator extends DefaultTextCreator
{
    private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(",");

    @Override
    public String getText()
    {
        Random random = new Random();
        int a = random.nextInt(10);
        int b = random.nextInt(10);
        int c = random.nextInt(10);
        int d = random.nextInt(10);
        int e = random.nextInt(10);
        int f = random.nextInt(10);
        StringBuilder suChinese = new StringBuilder();
        suChinese.append(CNUMBERS[a]);
        suChinese.append(CNUMBERS[b]);
        suChinese.append(CNUMBERS[c]);
        suChinese.append(CNUMBERS[d]);
        suChinese.append(CNUMBERS[e]);
        suChinese.append(CNUMBERS[f]);
        return suChinese.toString();
    }
}
